/*
 * Created on Nov 3, 2003
 * 
 * To change the template for this generated file go to Window - Preferences -
 * Java - Code Generation - Code and Comments
 */
package org.vectrics.recruiter.struts;

import java.util.Locale;

import javax.servlet.jsp.JspException;

import org.apache.log4j.Logger;
import org.apache.struts.action.ActionErrors;
import org.vectrics.hibernate.ThreadProperties;
import org.vectrics.provider.CoreServiceLocator;
import org.vectrics.recruiter.config.RecruitConfig;
import org.vectrics.struts.VectricsActionData;
import org.vectrics.user.Person;
import org.vectrics.user.web.struts.SaveUserAction;
import org.vectrics.user.web.struts.UserProfileForm;

public class SaveUserLoginAction extends SaveUserAction {
    private transient static Logger log = Logger.getLogger(SaveUserLoginAction.class);

    protected boolean getAuthUserMustBeSavingOwnInfo() {
        return (false);
    }

    protected boolean getEmailRequired() {
        return (false);
    }

    protected boolean getEmailMustBeUnique() {
        return (RecruitConfig.getRecruitInstance().getEmailMustBeUnique(ThreadProperties.getDomain()));
    }

    protected boolean getRolesRequired() {
        return (false);
    }

    protected boolean getUserNameRequired() {
        return (true);
    }

    protected boolean getSavePersonName() {
        return (true);
    }

    protected boolean getSaveEmails() {
        return (true);
    }

    protected boolean getGroupsRequired() {
        return (false);
    }

    protected boolean getSavePhoneNumbers() {
        return (false);
    }

    protected boolean getSaveHomeAddress() {
        return (false);
    }

    protected boolean getSaveWorkAddress() {
        return (false);
    }

    protected boolean getSaveRoles() {
        return (false);
    }

    protected boolean getSavePassword(UserProfileForm form) {
        return (true);
    }

    protected boolean getLoginUser() {
        return (true);
    }

    protected void beforeSave(Person user) {
        log.debug("beforeSave() - adding candidate role to user");
    }

    protected void saveExtendedData(Person person, VectricsActionData actionData, ActionErrors errors)
            throws JspException {
        log.debug("saveExtendedData() - no action");
    }

    protected void onUserAdded(Person addedUser, Person userWhoDidIt, Locale locale) {
        addedUser.addPrivilege("candidate.profile.access", addedUser.getDomain(), false);
        CoreServiceLocator.getPersonService().updatePerson(addedUser);
    }

    protected void onUserChanged(Person addedUser, Person userWhoDidIt, Locale locale) {
    }

}
